<script type="text/javascript">
	function doSearchArticle(value) {
		
	}
	
	//表格查询  
	function reloadArticle() {
		var params = article_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		article_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		article_list.datagrid('unselectAll');
		article_list.datagrid('uncheckAll');
	}


	function addArticle() {
		createFromWindow("新增消息信息", "article.do?editArticle", "article.do?saveArticle",
				function(data) {
					reloadArticle();
				});
	}

	function editArticle() {
		var rows = article_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "article.do?editArticle&articleId=" + rows[0].id,
					"article.do?saveArticle", function(data) {
						reloadArticle();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	function deleteArticle() {
		var rows = article_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('article.do?deleteArticleItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadArticle();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function deleteSelectArticle(){
	    var row = article_list.datagrid('getSelected');
	    if (row){
	        $.showr.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	                $.post('article.do?deleteArticle',{id:row.id},function(result){
	                	console.log(result);
	                    if (result.success){
	                        reloadArticle();    // reload the user data
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
</script>

<#assign operations = "[\{shiro:'forum:article:refresh',onClick:'lookArticle',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'forum:article:edit',onClick:'editArticle',src:'static/jmax/images/notes/note_edit.png',title:'编辑'},
	   					\{shiro:'forum:article:send',onClick:'sendArticle',src:'static/jmax/images/notes/note_go.png',title:'发送'},
	   					\{shiro:'forum:article:delete',onClick:'deleteArticle',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="article_list" toolbar="#articlelist_search" idField="id" 
			 url="article.do?loadList" rownumbers="true"
			 item="com.xdtech.forum.vo.ArticleItem"/>
		
		<div id="articlelist_search">
			<div id="article_toolbar" style="height: auto">
				
				<@eu.linkbutton showName="新增" shiro="forum:article:add" iconCls="icon-add" onclick="addArticle()"/>
				<@eu.linkbutton showName="删除" shiro="forum:article:delete" iconCls="icon-remove" onclick="deleteArticle()"/>
				<@eu.linkbutton showName="编辑" shiro="forum:article:edit" iconCls="icon-edit" onclick="editArticle()"/>
				<@eu.linkbutton showName="刷新" shiro="forum:article:refresh" iconCls="icon-reload" onclick="searchArticle()"/>
				
			</div>
		</div>
	</div>
</div>